package com.factory.code.controller;


import com.factory.code.controller.param.TemplatePageParam;
import com.factory.code.controller.vo.PageVO;
import com.factory.code.controller.vo.R;
import com.factory.code.lib.CustomTemplateManager;
import com.factory.code.repository.ent.TemplateCustomENT;
import com.factory.code.service.TemplateCustomService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("templateCustom")
@Api(tags = "项目/工程 管理")
public class TemplateCustomController {

    @Autowired
    private TemplateCustomService templateCustomService;


    @ApiOperation(value = "分页查询项目")
    @PostMapping("/getPage")
    public R<PageVO> list(@RequestBody TemplatePageParam param) {
        PageVO<TemplateCustomENT> page = templateCustomService.getPage(param);
        return R.ok(page);
    }

    @ApiOperation(value = "根据id查询模板")
    @PostMapping("/get/{id}")
    public R get(@PathVariable("id") int id) {
        return R.ok(templateCustomService.getById(id));
    }

    @ApiOperation(value = "添加项目")
    @PostMapping("/add")
    public R<Object> add(@RequestBody TemplateCustomENT customENT) {
        return templateCustomService.add(customENT);
    }

    @ApiOperation(value = "更新项目")
    @PostMapping("/update")
    public R<Object> update(@RequestBody TemplateCustomENT customENT) {
        return templateCustomService.update(customENT);
    }

    @ApiOperation(value = "删除项目")
    @PostMapping("/del")
    public R<Object> delete(@RequestBody TemplateCustomENT customENT) {
        return templateCustomService.delete(customENT);
    }

    @ApiOperation(value = "获取java方法")
    @PostMapping("/getJavaMethodList")
    public R getJavaMethodList() {
        return templateCustomService.getJavaMethodList();
    }


}
